﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace DBSourceToolsLib
{
    public class ProgressEventArgs : EventArgs
    {
        int m_CurrentIndex;
        int m_MaxIndex;
        string m_Message;
        bool m_IsError = false;

        public ProgressEventArgs(int currentIndex, int maxIndex, string strMessage)
        {
            if (currentIndex > maxIndex)
                this.m_Message = "error";
            this.m_CurrentIndex = currentIndex;
            this.m_MaxIndex = maxIndex;
            this.m_Message = strMessage;
        }

        public ProgressEventArgs(int currentIndex, int maxIndex, string strMessage, bool bIsError)
            : this(currentIndex, maxIndex, strMessage)
        {
            
            this.m_IsError = bIsError;
        }

        public string Percent
        {
            get
            {
                if (m_MaxIndex == 0)
                    return "0";
                if (m_CurrentIndex < 0)
                    return "-1";
//                float percent = (((float)m_CurrentIndex / (float)m_MaxIndex) * 100);
                return ((int)(((float)m_CurrentIndex / (float)m_MaxIndex) * 100)).ToString();
            }
        }
        public string Message
        {
            get { return m_Message; }
        }

        public bool IsError { get { return m_IsError; } }
    }
}
